package com.school.controller;


import com.school.domain.dto.product.ProductDTO;
import com.school.domain.dto.product.SelectProductDTO;
import com.school.domain.dto.product.UpdateProductDTO;
import com.school.domain.po.Product;
import com.school.domain.vo.PageVO;
import com.school.domain.vo.Result;
import com.school.service.ProductService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 货物信息表 前端控制器
 * </p>
 *
 * @author Forever
 * @since 2025-07-05
 */
@RestController
@RequestMapping("/product")
@Tag(name = "货物信息表接口")
public class ProductController {
    @Resource
    private ProductService productService;

    @Operation(summary = "新增货物")
    @PostMapping("/add")
    public Result<String> add(@RequestBody ProductDTO productDTO) {
        return Result.success(productService.addProduct(productDTO));
    }

    @Operation(summary = "修改货物")
    @PostMapping("/update")
    public Result<String> update(@RequestBody UpdateProductDTO updateProductDTO) {
        return Result.success(productService.updateProduct(updateProductDTO));
    }

    @Operation(summary = "删除货物")
    @GetMapping("/delete")
    public Result<String> delete(@RequestParam String skuCode) {
        return Result.success(productService.deleteProduct(skuCode));
    }

    @Operation(summary = "查询货物")
    @PostMapping("/selectList")
    public Result<PageVO<Product>> select(@RequestBody SelectProductDTO selectProductDTO) {
        return Result.success(productService.selectProduct(selectProductDTO));
    }
}

